//package com.electron.power.aio.mod.str;
//
//import java.nio.ByteBuffer;
//import java.nio.CharBuffer;
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//
//import org.smartboot.socket.Protocol;
//import org.smartboot.socket.transport.AioSession;
//import org.springframework.stereotype.Component;
//
//import com.electron.power.aio.common.DataExchangeUtils;
//import com.electron.power.model.mod.Mod;
//import com.electron.power.model.mod.ModBody;
//import com.electron.power.model.mod.ModData;
//import com.electron.power.model.mod.ModHead;
//import com.electron.power.model.mod.ModStr;
//
//import io.swagger.annotations.ApiModelProperty;
//import lombok.extern.slf4j.Slf4j;
//
//@Component
//@Slf4j
//public class ModStringProtocol implements Protocol<ModStr> {
//
//	@Override
//	public ModStr decode(ByteBuffer byteBuffer, AioSession<ModStr> session) {
//		try {
//			Integer frameLenth = Mod.getFrameLenth()*2;
//			log.debug("frame length is :{}",frameLenth);
//			if (byteBuffer.remaining() < frameLenth) {
//				return null;
//			}
//			byte[] dst = new byte[frameLenth];
//			byteBuffer.get(dst, 0, frameLenth);
//			String result = new String(dst);
//			ModStr modStr = new ModStr();
//			modStr.setData(result);
//			modStr.setCreatTime(LocalDateTime.now());
//			modStr.setLastTime(LocalDateTime.now());
//			return modStr;
//		} catch (Exception e) {
//			log.error("错误", e);
//			return null;
//		}
//	}
//
//	public ByteBuffer encode(ModStr msg, AioSession<ModStr> session) {
//		try {
//			int frameLength = Mod.getFrameLenth()*2;
//			ByteBuffer byteBuffer = ByteBuffer.allocate(frameLength);
//			// ByteBuffer byteBuffer = ByteBuffer.allocate(500);
//			byteBuffer.put("550300661A2B3C4D5E8000000000000000000000000000000000000003E70000000000000CE40000138800000000000000000000000000000000000003E70000000000000CFD0000138800000000000000000000000000000000000003E70000000000000C99000013887252".getBytes());
//			// b.putInt(s);
////			byteBuffer.rewind();
//			byteBuffer.flip();
//			return byteBuffer;
//		} catch (Exception e) {
//			log.error("写数据错误", e);
//			return null;
//		}
//	}
//	
//	public static void main(String[] args) {
//		String s = "550300661A2B3C4D5E8000000000000000000000000000000000000003E70000000000000CE40000138800000000000000000000000000000000000003E70000000000000CFD0000138800000000000000000000000000000000000003E70000000000000C99000013887252";
//		System.out.println(s.length());
//		System.out.println(Mod.getFrameLenth()*2);
//	}
//
//}
